package com.yanqu.road.server.cmd.union.parergon;

import com.yanqu.road.pb.union.Parergon;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.union.UnionParergonMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.string.StringUtils;

//@Cmd(code = Protocol.S_UNION_PARERGON_OPERATE_RECORD, desc = "经营记录")
public class OperateRecordCmd extends AbstractCommand {

    String unionUid;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        unionUid = player.getUserInfo().getUnionUid();
        if (StringUtils.isNullOrEmpty(unionUid)) {
            ret = GameErrorCode.E_PARERGON_NOT_IN_UNION;
        }
    }

    @Override
    public void sendData(GamePlayer player) {
        Parergon.OperateRecordRespMsg.Builder respMsg;
        if (ret != 0) {
            respMsg = Parergon.OperateRecordRespMsg.newBuilder();
        } else {
            respMsg = UnionParergonMgr.getOperateRecord(unionUid);
        }
        respMsg.setRet(ret);
        player.sendPacket(Protocol.U_UNION_PARERGON_OPERATE_RECORD, respMsg);
    }
}
